<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <script type="text/javascript" th:src="@{/js/echarts.min.js}"></script>
    <script type="text/javascript" th:src="@{/js/jquery-2.1.4.min.js}"></script>
    <title>Title</title>
</head>

<body>
<h4>用户成交额</h4>
<div id="main2" style="width: 600px;height:400px;"></div>
<div id="main" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
    $(function(){
        init()
        init2()
    })


    function init(){
        //基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'),'light');
        $.ajax({
            url:"../echarts/findEcharts",
            type:"get",
            dataType:"JSON",
            success:function(data){
                var arr = [];
                var arr1= [];
                for (var i = 0; i < data.length; i++) {
                    arr.push(data[i].shopTotal)
                    arr1.push(data[i].realityShopTotal)
                }
                var option = {
                    title: {
                        text: '近七天订单成交额'//标题
                    },
                    tooltip: {},//提示信息
                    legend: {
                        data:['金额']
                    },
                    xAxis: {
                        data: ["周一","周二","周三","周四","周五","周六","周日"]
                    },
                    yAxis: {},
                    series: [{
                        name: '金额',
                        type: 'bar',
                        data: arr1
                    }]
                };
                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);
            }
        })
    }


    function init2(){
        var myChart = echarts.init(document.getElementById('main2'),'light');
        $.ajax({
            url:"../echarts/findEcharts2",
            type:"get",
            dataType:"JSON",
            success:function(data){
                myChart.setOption({
                    series: [
                        {
                            name: '访问来源',
                            type: 'pie',
                            radius: '50%',
                            data: data,
                            emphasis: {
                                itemStyle: {
                                    shadowBlur: 10,
                                    shadowOffsetX: 0,
                                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                                }
                            }
                        }
                    ]
                })
            }
        })
    }
</script>
</body>
</html>